<!DOCTYPE html>
<html>
<head>
	<title>Laporan Pendaftaran Siswa</title>
	<style type="text/css">
		body {
			font-family: 'arial', 'times new roman';
			font-size: 12px;
		}
		table {
			border-collapse: collapse;
			width: 100%;
			border-color: #000;
		}
		table thead tr th {
			padding: 5px 8px;
			background: #eee;
			font-size: 13px;
			border-bottom: 2px solid;
		}
		table tbody tr td {
			padding: 5px 5px;
		}
		table > tbody > tr:nth-child(odd) > td {
			background: #fafafa;
		}
		h1 {
			font-size: 18px;
		}
	</style>
</head>
<body>
<?php
include "config/koneksi.php";
include "config/tanggalan.php";
$tgl_daftar=$_POST['tanggal'];
$proli=$_POST['proli'];
if($proli=="semua"){
	$str_proli="Semua";
	$filter_proli="";
}else{
	$sql="select * from tb_proli where kd_proli='".$proli."'";
	$qry=mysql_query($sql);
	$hasil=mysql_fetch_array($qry);
	$str_proli=$hasil['proli'];
	$filter_proli=" and a.proli='".$proli."'";
	
}
?>
<h1 align="center">LAPORAN PENDAFTARAN SISWA</h1>
<h2 align="center">Per Tanggal <?php echo tanggalan($tgl_daftar);?></h2>
<h2 align="center">Program Keahlian <?php echo $str_proli;?></h2>
<table border="1">
	<thead>
		<tr>
			<th width="4%">No</th>
			<th >No Pendaftaran</th>
			<th >Nama Siswa</th>
			<th >Asal Sekolah</th>
			<th >Proli</th>
			<th >Total Nilai</th>
			
		</tr>
	</thead>
	<tbody>
	<?php
	
	$sql_urut="SELECT * FROM (
			SELECT no_pendaftaran,id_pendaftaran,nama,matematika,indonesia,inggris, ipa ,asal_sekolah,
			((4*matematika)+(1*indonesia)+(3*inggris)+(2*ipa)) AS jumlah,b.proli
			FROM tb_pendaftar a left join tb_proli b on b.kd_proli=a.proli
			WHERE tgl_daftar='".$tgl_daftar."' $filter_proli) AS data_raw 
			ORDER BY jumlah DESC,matematika  DESC ";
			//echo $sql_urut;
			$qry=mysql_query($sql_urut);
			$no=1;
			while($hasil=mysql_fetch_array($qry)){
	?>
		<tr>
			<td><?php echo $no?></td>
			<td><?php echo $hasil['no_pendaftaran']?></td>
			<td><?php echo $hasil['nama']?></td>
			<td><?php echo $hasil['asal_sekolah']?></td>
			<td><?php echo $hasil['proli']?></td>
			<td><?php echo $hasil['jumlah']?></td>
		</tr>
<?php
$no++;
}
?>

	</tbody>
</table>


</body>
</html>